package org.keyyond.ms.scheduler.service.impl;

import org.keyyond.ms.core.util.HttpUtil;
import org.keyyond.ms.scheduler.service.MsZbgsJobService;
import org.keyyond.ms.scheduler.util.EncryptUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;

@Service
@RefreshScope
public class MsZbgsJobServiceFallback implements MsZbgsJobService{
	
	@Value("${calculateInterestUrl}")
	private String calculateInterestUrl;
	
	@Value("${temporaryEstimateOfIncomeUrl}")
	private String temporaryEstimateOfIncomeUrl;
	
	@Value("${redDashedUrl}")
	private String redDashedUrl;
	
	@Value("${authParam}")
	private String authParam;
	
	private static Logger logger = LoggerFactory.getLogger(MsZbgsJobServiceFallback.class);
	
    @Override
    public String temporaryEstimateOfIncomeJob() {
    	String encrypt = EncryptUtil.encrypt(authParam);
		String result=null;
		if(encrypt!=null){
			result=HttpUtil.sendPost(temporaryEstimateOfIncomeUrl+encrypt, "{}", "UTF-8");
		}else{
			logger.info("没有权限！");
		}
    	
	return result;
    }

	@Override
	public String calculateInterestJob() {
		// TODO Auto-generated method stub
		String encrypt = EncryptUtil.encrypt(authParam);
		String result=null;
		if(encrypt!=null){
			result=HttpUtil.sendPost(calculateInterestUrl+encrypt, "{}", "UTF-8");
		}else{
			logger.info("没有权限！");
		}
		return result;
	}

	@Override
	public String redDashedJob() {
		// TODO Auto-generated method stub
		String encrypt = EncryptUtil.encrypt(authParam);
		String result=null;
		if(encrypt!=null){
			result=HttpUtil.sendPost(redDashedUrl+encrypt, "{}", "UTF-8");
		}else{
			logger.info("没有权限！");
		}
		return result;
	}


}
